Skip to content

Conversation

diniamo
Copy link

@diniamo diniamo commented Jan 13, 2024

Implements custom image support in the Match object, and adds support for it and also icons in the Stdin plugin (without breaking anything)

Feel free to point out anything I should change/forgot, a few key things I couldn't decide on myself:

  • Maybe merge this feature into the icon field of Match somehow?
  • Should hide_icons also hide images? Or should images always be shown? Or should they have their own switch? I went with the first option because custom images are supposed to override icons, sort of.
  • This is not really up to decision, because GTK CSS does not support changing the size of GtkImages, but I had to go with having a max width and height in the config file instead.
  • The default values for the 2 options mentioned above are undecided, I put 150 for max width, and 100 for max height.

For the Stdin part of it:

  • The title and the image path is currently separated by a tab character, is there a better way of separating data?
  • How should I go about also adding support for normal icons in Stdin? (see Stdin readme for how it is currently done)

Breaking changes:

  • Plugins need to add the new field (avoidable if the image field is merged into the icon field)
  • (Not really) 2 new config fields
  • Can't pipe tabs into the Stdin plugin now (maybe avoidable?)

Closes #126

@diniamo diniamo changed the title Custom image Custom image support Jan 13, 2024
@Kirottu
Copy link
Collaborator

Kirottu commented Aug 25, 2025

This PR will not be compatible with the relm4 port, so will need to be redone and reconsidered.

Custom image support would definitely be nice, but at least the current implementation with the stdin does not really feel good. It would be better if the stdin plugin had an option to parse json as the input instead of just newlines.

@rimrimnyan
Copy link

What if instead of creating a new "image" field, just use the existing "icon" field?
Check if the value provided to "icon" is a path. If it is, then display the image. If not, it will act as the old "icon" field.

Also, I wonder if support for animated images would be possible.

@Kirottu
Copy link
Collaborator

Kirottu commented Sep 11, 2025

Currently we are discussing this in the Matrix room, and are thinking of making a separate field that would allow for different previews & preview types for plugins. How they are drawn is still up for debate though.

@diniamo
Copy link
Author

diniamo commented Sep 12, 2025

What if instead of creating a new "image" field, just use the existing "icon" field? Check if the value provided to "icon" is a path. If it is, then display the image. If not, it will act as the old "icon" field.

Also, I wonder if support for animated images would be possible.

This was a while ago, but IIRC, there was a reason I didn't do that.

@tylerjl
Copy link

tylerjl commented Sep 30, 2025

I wanted to briefly note here that I'm migrating away from rofi+cliphist and would love to use anyrun in combination with a clipboard manager that can provide image previews, so if this MR could be leveraged to support that, it'd be ideal.

The rofi + cliphist implementation is pretty hacky (it generates thumbnails on the fly that it injects with rofi's unique string interpolation syntax) but I was imagining potentially doing something like talking to the sqlite backend for clipvault to retrieve images from within rust to more natively have image bytes to work with and potentially render somewhere.

Of course you could do this with an anyrun daemon in the background listening to wl-copy or whatever but in either case we'd be working with image data bytes.

@Kirottu
Copy link
Collaborator

Kirottu commented Oct 1, 2025

As it is right now, no plugin can run as a daemon, so unless the clipboard manager was implemented inside Anyrun proper (which doesn't sound great to me since it sidesteps the whole point of plugins being independent) it wouldn't really work out. As for the image support itself, I think a better way would be to design a system that would:

  • Allow for multiple different preview types, this could be done by having something like a Preview enum as a part of matches.
    • This would make it extensible, allowing stuff like text file preview as well.
  • Allow the preview data to be provided as is or dynamically generated, this would require some sort of a callback into the plugin for generating the preview. So another function as a part of the plugin definition is probably necessary (but should be optional).
    • This would be useful for stuff like the niri-focus plugin, where window previews would only need to be generated on demand.

Of course the UI stuff also needs some thought (where & how the preview should be shown) but that can be rapidly iterated upon after the underlying stuff is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a way to properly display custom images
4 participants